#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@File    ：timeit.py
@Author  ：zhaolin
@Date    ：2022/3/14 15:22
"""
import time
from functools import wraps


def timeit(fn):
    """计算函数运行时间的装饰器"""

    @wraps(fn)
    def measure_time(*args, **kwargs):
        t1 = time.time()
        result = fn(*args, **kwargs)
        t2 = time.time()
        print(f"@timeit: {fn.__name__} took {t2 - t1: .5f} s")
        return result

    return measure_time
